Math.Log with variable double

Hello everyone, I am a new user of survey solution and I am asking for help.
How to use Math.Log with double variable. I got error:
Argument 1: impossible conversion from ‘double’ to 'double?.
Math.Exp( 0.3825021 * Math.Log(tri3_tcd_value) + 0.3321277 * Math.Log(tri3_fl_value) + 2.63416 )

Please check the exact text of the error message. Please include a screenshot if possible.

Thank for your answer, the extact error is: Argument 1: conversion impossible de ‘double’ en ‘double?’ in french so as Argument 1: impossible conversion from ‘double’ to 'double?

You have to convert the argument of the Math.Log function like this: Math.Log((double)Pi)

probably the message is the opposite: "can’t convert double? into double".
In that case, indeed, @kv700032’s suggestion is correct, you need to directly indicate that you are agreeing your expression will only be applied when the variable mentioned in log has a value.

Thank you, can you please give me exemple with my variable? It’s like this : Math.Log(double(tri3_tcd_value)) ? tri3_tcd_value is my variable.

No, this is the right.
Math.Log((double)tri3_tcd_value) + (0.3321277 * Math.Log((double)tri3_tcd_value))+...


+ (0.3321277 * Math.Log((double)tri3_tcd_value))+...

notice: (double)X not double(X)

See Explicit conversions section.

1 Like

Sorry. I overlooked the order of the parentheses, I thought it was clear in the previous explanation how to use the cast in variable.

I have corrected my previous post and @sergiy’s explanation is very timely because they are completely different situations.

Thank you very much, its work perfectly.

Thank you for confirming!

For those playing along at home, the formula is used to estimate gestational age from various measurements, and it appears in he Lancet Glob Health 2020 Aprl 8(4) issue:

(see formula 2c in eTable 3 of the Supplementary appendix).

@CheickAhmed , make sure you express clearly the units for measurement (cm if I am not mistaken for both TCD and FL, and days for the resulting GA) in the questionnaire.

Best, Sergiy

Thank you, yes unit is in cm. We remove 7* in to formula to get GA in week.